home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / LDB171.ARJ / MINT.CPP < prev    next >
C/C++ Source or Header  |  1992-05-12  |  2KB  |  121 lines

  1. /*
  2.     mint.cpp -- Loose Data Binder v 1.7:
  3.         mutually owned and persistent
  4.         "int form."
  5.  
  6.     (C) Copyright 1992  John W. Small
  7.     All rights reserved
  8.  
  9.     PSW / Power SoftWare
  10.     P.O. Box 10072
  11.     McLean, Virginia 22102 8072 USA
  12.     (703) 759-3838
  13.  
  14.     This file was created by cloning fmutual.cpp
  15.     and
  16.  
  17.     replacing:    with:
  18.  
  19.     CLASS        Mint
  20.     CPTR        MinT
  21.     BASE        Mutual
  22. */
  23.  
  24.  
  25. #ifndef Mint_HPP
  26. #include "mint.hpp"
  27. #endif
  28.  
  29. int Mint::initData(int i)
  30. {
  31.     // initialize any Mint-declared data
  32.     // members here
  33.     this->i = i;
  34.     return 1;  // success
  35. }
  36.  
  37. void Mint::fput(ostream& os)
  38. {
  39.     Mutual::fput(os);
  40.     os << i << Mendm;
  41.     if (!os)
  42.         error("unable to store Mint "
  43.             "data on stream");
  44. }
  45.  
  46. MutuaL Mint::fget(istream& is, MutuaL InstancE)
  47. {
  48.     int newed;
  49.     MinT thiS;
  50.     int i;
  51.  
  52.     is >> i >> Mnextm;
  53.     if (!is)  {
  54.         serror("unable to load Mint "
  55.             "data from stream",
  56.             ID_Mint);
  57.         return MutuaL0;
  58.     }
  59.     if (InstancE)  {
  60.         newed = 0;
  61.         thiS = (MinT) InstancE;
  62.     }
  63.     else  {
  64.         if ((thiS = new Mint(initVFTsEtc))
  65.             == MinT0)  {
  66.             serror("unable to construct "
  67.                 "new Mint for "
  68.                 "loading",
  69.                 ID_Mint);
  70.             return MutuaL0;
  71.         }
  72.         newed = 1;
  73.         InstancE = (MutuaL) thiS;
  74.     }
  75.     if (!Mutual::fget(is,InstancE))  {
  76.         if (newed)
  77.             delete (voiD) thiS;
  78.         return MutuaL0;
  79.     }
  80.     if (!thiS->initData(i))  {
  81.         serror("unable to initialize Mint "
  82.             "from reloaded stream data",
  83.             ID_Mint);
  84.         if (newed)
  85.             delete (voiD) thiS;
  86.         return MutuaL0;
  87.     }
  88.     return InstancE;
  89. }
  90.  
  91.  
  92. Mint::Mint (int i) : Mutual(initVFTsEtc)
  93. {
  94.     (void) initData(i);
  95. }
  96.  
  97. Mint::Mint(Mint& c) : Mutual(c)
  98. {
  99.     // copy initializer constructor
  100.     this->i = c.I();
  101. }
  102.  
  103. int Mint::operator=(Mutual& m)
  104. {
  105.     this->i = ((MinT)&m)->I();
  106. // Assignment is not the same as copy initialize!
  107. // In this trival case the semantics are the same.
  108.     return 1;  // enabled
  109. }
  110.  
  111. MutuaL Mint::clone()
  112. {
  113.     // invokes copy initializer constructor
  114.     return (MutuaL) new Mint(*this);
  115. }
  116.  
  117. Mint::~Mint()
  118. {
  119.     // ???
  120. }
  121.